Difference between () and [] in Perl6 [migrated]

Posted by Ask and Learn on Programmers See other posts from Programmers or by Ask and Learn
Published on 2014-06-11T10:22:18Z Indexed on 2014/06/11 15:40 UTC
Read the original article Hit count: 287

Filed under:

Learning Perl 6 and had trouble to understand following Perl 6 one liner.

version of Perl 6 -> rakudo-star: stable 2014.04 (bottled)

This works fine, array/list is sorted [njia@mb-125:~] : perl6 -e 'say [2443,5,33, 90, -9, 2, 764].sort' -9 2 5 33 90 764 2443

But this does not sort the array/list, if [].sort works why @s.sort does not? [njia@mb-125:~] : perl6 -e 'my @s = [2443,5,33, 90, -9, 2, 764]; @s.sort.say' 2443 5 33 90 -9 2 764

Change from [] to () [njia@mb-125:~] : perl6 -e 'my @s = (2443,5,33,90,-9,2,764); @s.sort.say' -9 2 5 33 90 764 2443

© Programmers or respective owner

Related posts about perl